import {getBanner} from '@/api/banner'
import { defineStore } from 'pinia';
import { ref, type Ref } from 'vue';
import type {bannerData} from '@/type/store'

export const useBannerStore = defineStore('banner', () => {
  const loadingRef = ref(false);
  const dataRef:Ref<bannerData | null> = ref(null)
  async function fetchData () {
    if(dataRef.value?.length) return;
    loadingRef.value = true;
    const resp = await getBanner();
    dataRef.value = resp;
    loadingRef.value = false;
  }
  return {loadingRef, dataRef, fetchData}
})